home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue55 / ccorn / Ctrl.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-02-07  |  1.2 KB  |  54 lines

  1. unit Ctrl;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, ColorGrd, ExtCtrls, Srv_TLB, Buttons;
  8.  
  9. type
  10.   TControlForm = class(TForm)
  11.     BtnExit: TButton;
  12.     Edit: TEdit;
  13.     BtnSend: TButton;
  14.     procedure BtnExitClick(Sender: TObject);
  15.     procedure BtnSendClick(Sender: TObject);
  16.     procedure FormCreate(Sender: TObject);
  17.   private
  18.     FIntf: IQTest;
  19.   end;
  20.  
  21. var
  22.   ControlForm: TControlForm;
  23.  
  24. implementation
  25.  
  26. {$R *.DFM}
  27.  
  28. uses ComObj, ActiveX;
  29.  
  30. // Need to import CoGetObject because import in the ActiveX unit is incorrect:
  31. function MyCoGetObject(pszName: PWideChar; pBindOptions: PBindOpts;
  32.   const iid: TIID; out ppv): HResult; stdcall; external 'ole32.dll' name 'CoGetObject';
  33.  
  34. procedure TControlForm.BtnExitClick(Sender: TObject);
  35. begin
  36.   Close;
  37. end;
  38.  
  39. procedure TControlForm.BtnSendClick(Sender: TObject);
  40. begin
  41.   FIntf.SendText(Edit.Text, Now);
  42.   Edit.Clear;
  43. end;
  44.  
  45. procedure TControlForm.FormCreate(Sender: TObject);
  46. const
  47.   SMoniker: PWideChar = 'queue:/new:{64C576F0-C9A7-420A-9EAB-0BE98264BC9D}';
  48. begin
  49.   // Create object using a moniker that specifies queued creation
  50.   OleCheck(MyCoGetObject(SMoniker, nil, IQTest, FIntf));
  51. end;
  52.  
  53. end.
  54.